package com.yazdankhah.listeners;

import com.yazdankhah.utils.DataTools;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 *
 * @author ahmad
 */
public class ContextListener implements ServletContextListener {
  
  
  private ServletContext context = null;


  @Override
  public void contextInitialized(ServletContextEvent event) {
    
    context = event.getServletContext();
    String contextPath = context.getContextPath();
    System.out.println("contextPath = [" + contextPath + "]");
    
    String rootRealPath = context.getRealPath("/");
    System.out.println("rootRealPath = [" + rootRealPath + "]");
    
    
    DataTools.loadMyQuran(rootRealPath);
    
//    System.out.println("(1,7) = [" + DataTools.lookupQuranVerse(1, 7) + "]");
//    System.out.println("(2,1) = [" + DataTools.lookupQuranVerse(2, 1) + "]");
//    System.out.println("(1,3) = [" + DataTools.lookupQuranVerse(1, 3) + "]");
    
    
  } //method


  @Override
  public void contextDestroyed(ServletContextEvent event) {
    
    context = event.getServletContext();
    context = null;
  } //method
  
} //class
